﻿<%@ Page Title="文章" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="ListArticles.aspx.cs" Inherits="Manage_ListArticles" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
    <%
        if (Page.User.Identity.IsAuthenticated == false)
        {
            Response.Redirect("~/Manage/Default.aspx");
        }     
    %>

    <script type="text/javascript">
        function DeleteArticle() {
            if (confirm('确认删除当前文章信息吗？')) {
                return true;
            } else {
                return false;
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <div style="margin:5px 0px 5px 0px;">
        <asp:Label id="ForumLabel" runat="server">选择栏目：</asp:Label>
        <asp:DropDownList ID="ForumList" runat="server" AutoPostBack="True"></asp:DropDownList>
    </div>
    <div style="margin:5px 0px 5px 0px;">
        <asp:GridView ID="ArticleView" runat="server" BackColor="White" 
            BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" 
            DataSourceID="ArticleDataSource" AutoGenerateColumns="False" 
            DataKeyNames="ID" AllowPaging="True">
            <Columns>
                <asp:TemplateField  HeaderText="&nbsp;">
                <ItemStyle  Width="40px"  HorizontalAlign="Center"/>
                <ItemTemplate>
                    <asp:LinkButton ID="DeleteButton" runat="server" CommandArgument='<%#Eval("ID") %>' OnCommand="Command_DeleteArticle" OnClientClick="return DeleteArticle();">删除</asp:LinkButton>
                </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="文章标题" >
                <ItemStyle  Width="200px" />
                <ItemTemplate>
                <a href='./EditArticle.aspx?aid=<%#Eval("id") %>'><%#Eval("Title") %></a>
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:BoundField DataField="Subtitle" HeaderText="文章子标题" 
                    SortExpression="Subtitle" >
                <ItemStyle Width="200px" />
                </asp:BoundField>


                <asp:TemplateField HeaderText="所属栏目">
                <ItemStyle Width="100px" HorizontalAlign="Center"/>
                    <ItemTemplate>
                        <asp:LinkButton ID="ForumLink" runat="server" CommandArgument='<%#Eval("Forum.ID") %>' OnCommand="Command_ChangeForum"><%#Eval("Forum.Name") %></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="Keyword" HeaderText="关键字" 
                    SortExpression="Keyword" >
                <ItemStyle Width="100px" />
                </asp:BoundField>
               
             <asp:TemplateField HeaderText="发布者">
                <ItemStyle  Width="80px" HorizontalAlign="Center" />
                <ItemTemplate>
                <%#Eval("Creator.Name") %>
                    </ItemTemplate>
                </asp:TemplateField>


                <asp:TemplateField HeaderText="发布时间" >
                <ItemStyle Width="100px" HorizontalAlign="Center" />
                <ItemTemplate>
                       <%# string.Format("{0:yyyy年MM月dd日}", Eval("Published")) %>
                    </ItemTemplate>
                </asp:TemplateField>


                <asp:BoundField DataField="Clicked" HeaderText="浏览量" SortExpression="Clicked" >
                <ItemStyle Width="50px" HorizontalAlign="Center" />
                </asp:BoundField>
              
 
                <asp:TemplateField HeaderText="静态页面">
                <ItemStyle  Width="60px" HorizontalAlign="Center" />
                <ItemTemplate>
                <a href='../Statics/<%#Eval("Url") %>' target="_blank">查看</a>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <FooterStyle BackColor="White" ForeColor="#000066" />
            <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
            <RowStyle ForeColor="#000066" />
            <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#F1F1F1" />
            <SortedAscendingHeaderStyle BackColor="#007DBB" />
            <SortedDescendingCellStyle BackColor="#CAC9C9" />
            <SortedDescendingHeaderStyle BackColor="#00547E" />
        </asp:GridView>
    </div>    
    
    <asp:LinqDataSource ID="ArticleDataSource" runat="server" 
        ContextTypeName="TreasurerDataContext" EntityTypeName="" 
        TableName="Articles" OrderBy="Published desc" 
        Select="new (ID, Title, Subtitle, Keyword, Body, Published, Clicked, Url, Creator, Forum)">
    </asp:LinqDataSource>
    
    <asp:LinkButton ID="NewArticleButton" runat="server" 
        onclick="NewArticleButton_Click">新建文章</asp:LinkButton>
        &nbsp;&nbsp;
    <asp:LinkButton ID="RegenerateArticles" runat="server" 
        onclick="RegenerateArticles_Click">重新生成全部文章</asp:LinkButton>
</asp:Content>

